package cc.wsyw126.java.nowcoder.weizhongyinhang;


import java.util.Scanner;

/**
 * Created by Administrator on 2017/4/25.
 * 在一串数中找到和为指定数的可能组合数
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int count = 0;
            String s = scanner.nextLine();
            int n = Integer.valueOf(s);
            String s1 = scanner.nextLine();
            String[] split = s1.split(" ");
            int n1 = Integer.valueOf(split[0]), n2 = Integer.valueOf(split[1]), n3 = Integer.valueOf(split[2]);
            for (int i = 0; i <= n3; i++) {
                for (int j = 0; j <= n2; j++) {
                    for (int k = 0; k <= n1; k++) {
                        int sum = i*10 + j*8 + k*5;
                        if (sum > n) break;
                        else if (sum == n) count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}
